<?php


namespace app\api\validate;


use think\facade\Validate;

class UserValidate extends Validate
{
    protected $rule=[
        'user_name'=>'max:20|requireIf:account_type,1',
        'school_name'=>'max:50|requireIf:account_type,2',
        'school_address'=>'10|requireIf:account_type,2',
        'mobile'=>'require|length:11|',
//        unique:user
        'password'=>'require|min:6',
        'account_type'=>'require|in:1,2',
    ];
    protected $message=[
        'user_name.require' => '用户姓名不能为空',
        'user_name.max' => '用户姓名不能超过20个字符',
        'school_name.require' => '学校名称不能为空',
        'school_address.require' => '学校地址不能为空',
        'mobile.require' => '手机号不能为空',
        'password.require' => '密码不能为空',
        'password.min' => '密码长度不能小于6位',
        'account_type.require' => '账号类型不能为空',
        'account_type.in' => '账号类型只能是1或2',
    ];
    protected $scene=[
//        'register'=>['user_name','mobile']
        'login'=>['mobile','possword']
    ];
}